package cn.dlc.com.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

/**
 * @author 邓立川
 * @date 2021/11/21 10:02
 * @desc springmvc的核心配置
 */
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "cn.dlc.com",
        // 单纯扫描controller和RestController
        includeFilters = {
                @ComponentScan.Filter(type = FilterType.ANNOTATION,value = RestController.class),
                @ComponentScan.Filter(type = FilterType.ANNOTATION, value = Controller.class)} )
public class SpringMvcConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        // 默认打开login
        registry.addRedirectViewController("/","login");
    }
}
